<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>校园综合服务系统</title>
    <head>
        <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
        <script>
            $(document).ready(function(){
                $("form").submit(function(event){
                    event.preventDefault();
                    var sto = window.localStorage.getItem("username")
                    var data = $.parseJSON(sto)

                    if (data.student_id === 0){
                        var formData = $(this).serialize() + "&author_id=" + data.teacher_id;
                    }else if(data.teacher_id === 0){
                        var formData = $(this).serialize() + "&author_id=" + data.student_id;
                    }
                    $.post("http://localhost:80/blog/add-blog",formData,function (response){
                        var data = $.parseJSON(response)
                        if (data.code == "00000") {
                            alert("发帖成功，点击跳转")
                            $(location).attr("href", "all_blogs.html")
                        } else {
                            alert("发帖失败")
                        }
                    });
                });
            });
        </script>
        </head>
    <style>
        .container {
            text-align: center;
        }
    </style>
</head>
<body>
    
    <div class="container">    
        <form action="#" method="post">
            标题：<input type="text" name="title" /><br>
            内容：<textarea name="content" rows="10" cols="30"></textarea><br>
            <input type="radio" name="anonymous" value="0">实名发布
            <input type="radio" name="anonymous" value="1">匿名发布
            <input id="publish" type="submit" value="发布">
        </form>
    </div>
    


</body>
</html>